﻿<%@ WebHandler Language="C#" Class="Delete_Item" %>

using System;
using System.Web;
using System.Data;
using System.Data.Common;
//using System.Web.SessionState;

//public class Delete_Item : IHttpHandler, IRequiresSessionState
public class Delete_Item : IHttpHandler{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        /* 管理员信息验证 */
        if (!Admins.IsLogin(true))
            Utils.ShowEnd(context, -2);

        int admin_id = Admins.IsLogin();

        /* 外部数据安全接受 */
        Int32 Item_Id = Convert.ToInt32(context.Request.Params["Item_Id"].ToString());
        Int32 Item_Typ = Convert.ToInt32(context.Request.Params["Item_Typ"].ToString());
        /* 数据完整性验证 */
        if (Item_Id < 1 && Item_Typ < 1)
            Utils.ShowEnd(context, -1);
        else if (Item_Typ > 4288)
            Utils.ShowEnd(context, -1);

        /* 数据库参数生成 */
        DbParameter[] param = { 
            DBHelper.MakeInParam("@Item_Id",(DbType)SqlDbType.BigInt,8,Item_Id),
            DBHelper.MakeInParam("@Item_Typ",(DbType)SqlDbType.TinyInt,1,Item_Typ),
            DBHelper.MakeInParam("@Admin_Id",(DbType)SqlDbType.Int,4,admin_id)
        };
        /* 返回数据处理结果 */
        Utils.ShowEnd(context, DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "Delete_Item", param).ToString());
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}